export const getRandom = iLength => {
  let currentResult = Date.now() + ''
  let aItems = [
    '0',
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
    'A',
    'B',
    'C',
    'D',
    'E',
    'F',
    'G',
    'H',
    'I',
    'J',
    'K',
    'L',
    'M',
    'N',
    'O',
    'P',
    'Q',
    'R',
    'S',
    'T',
    'U',
    'V',
    'W',
    'X',
    'Y',
    'Z'
  ]
  let iCount = aItems.length
  iLength = iLength - currentResult.length
  for (let index = 0; index < iLength; index++) {
    let iIndex = Math.floor(Math.random() * iCount)
    currentResult += aItems[iIndex]
  }
  return currentResult
}
/**
   * 获取localstrage
   * @param {*} skey
   * @param {*} isObject
   */
export const getLocalStorage = (skey, isObject = true) => {
  let result = localStorage.getItem(skey) || ''
  if (isObject) {
    result = result || '{}'
    return JSON.parse(result)
  }
  return result
}
/**
   * 设置localstorage
   * @param {*} skey
   * @param {*} svalue
   * @param {*} isObject
   */
export const setLocalStorage = (skey, value = {}, isObject = true) => {
  if (isObject) {
    value = JSON.stringify(value)
  }
  localStorage.setItem(skey, value)
}
